<template>
  <div class="index">
    <el-container>
      <el-aside width="200px">
        <el-row class="tac">
          <el-col :span="24">
            <el-menu
              class="el-menu-vertical-demo"
              text-color="#fff"
              active-text-color="#ffd04b"
              unique-opened
              router
            >
              <el-menu-item>
                <!-- <i class="el-icon-view"></i> -->
                <span slot="title">首页</span>
              </el-menu-item>
              <div v-for="item in powerList.menus" :key="item.id">
                <!-- 1.有children -->
                <el-submenu :index="item.id+''" v-if="item.children">
                  <template slot="title">
                    <i :class="item.icon"></i>
                    <span>{{item.title}}</span>
                  </template>
                  <el-menu-item
                    v-for="i in item.children"
                    :key="i.id"
                    :index="'/index'+i.url"
                  >{{i.title}}</el-menu-item>
                </el-submenu>
                <!-- 2.无children -->
                <el-menu-item :index="item.url" v-else>
                  <!-- <i class="el-icon-view"></i> -->
                  <span slot="title">{{item.title}}</span>
                </el-menu-item>
              </div>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-container>
        <el-header>
          admin
          <el-button @click="cancle">退出</el-button>
        </el-header>
        <el-main>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/index/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>{{$route.meta.title}}</el-breadcrumb-item>
          </el-breadcrumb>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  computed: {
    ...mapGetters({
      powerList: "user",
    }),
  },
  mounted() {
    console.log(this.$store);
  },
  methods: {
    ...mapActions({
      changeUser: "reqlogin",
    }),
    cancle() {
      this.changeUser({});
      this.$router.push("/login");
    },
  },
};
</script>

<style lang="less">
@import "../../less/index.less";
.el-header {
  text-align: right;
  line-height: 60px;
}
.el-breadcrumb {
  margin-bottom: @margin;
}
.el-container {
  height: 100vh;
  // background: chartreuse;
}
.el-aside {
  background: @info;
}
.el-header {
  background: @header-color;
}

.el-menu {
  background: @info;
}

.el-menu-item:hover {
  background: @header-color;
}

.el-submenu__title:hover {
  background: @header-color;
}
// .el-menu-vertical-demo,.el-menu{
//   background: @info;
// }
// .el-menu-item:focus, .el-menu-item:hover,/deep/.el-submenu__title:hover{
//   background: @header-color;
// }
</style>